#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016-2018, Niklas Hauser
# Copyright (c) 2017, Fabian Greif
# Copyright (c) 2020, Erik Henriksson
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------

def init(module):
    module.name = ":board:feather-m0"
    module.description = """\
# Adafruit Feather-M0

At the Feather M0's heart is an ATSAMD21G18 ARM Cortex M0 processor,
clocked at 48 MHz and at 3.3V logic, the same one used in the new Arduino Zero.
This chip has a whopping 256K of FLASH (8x more than the Atmega328 or 32u4)
and 32K of RAM (16x as much)! This chip comes with built in USB so it has
USB-to-Serial program & debug capability built in with no need for an FTDI-like chip.

https://www.adafruit.com/product/2772
"""

def prepare(module, options):
    if not options[":target"].partname.startswith("samd21g18a"):
        return False

    module.depends(":platform:gclk",
                   ":platform:core",
                   ":platform:clock",
                   ":platform:gpio",
                   ":platform:uart:0",
                   ":platform:usb",
                   ":debug")
    return True

def build(env):
    env.outbasepath = "modm/src/modm/board"
    env.substitutions = {
        "with_logger": True,
        "with_assert": True,
    }
    env.template("../board.cpp.in", "board.cpp")
    env.copy('.')
